from selenium.webdriver.common.by import By


def get_select(loc, num):
    # print(loc[:loc.rfind('[') + 1] + f'{num}]')
    return By.XPATH, loc[:loc.rfind('[') + 1] + f'{num}]'


# iframe的id
iframe_id = By.ID, 'ifcontent'

# 订单管理大菜单
order_a = By.XPATH, '//*[@id="admin-offcanvas"]/div/ul/li[7]/a'
# 订单管理
order_manager = By.XPATH, '//*[@id="power-menu-177"]/li[1]/a'
# 搜索按钮
butt_search = By.XPATH, '/html/body/div[2]/div/form/div[2]/button'
# 重置搜索按钮
butt_search_reset = By.XPATH, '/html/body/div[2]/div/form/div[2]/a'
# 基础信息（订单id、订单号、商品信息）
input_order_id = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[1]/input'
# 用户信息（用户名、手机）
input_user_name = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[2]/input'
# 订单状态
select_order_state = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[3]/div'


def order_state(num):
    return get_select('/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[3]/div/div/ul/li[0]', num)


# 支付状态
select_pay_state = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[4]/div'


def pay_state(num):
    return get_select('/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[4]/div/div/ul/li[0]', num)


# 总价
input_min_money = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[5]/div/input[1]'
input_max_money = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[5]/div/input[2]'
# 支付金额
input_min_pay = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[6]/div/input[1]'
input_max_pay = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[6]/div/input[2]'
# 单价
input_min_price = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[7]/div/input[1]'
input_max_price = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[7]/div/input[2]'
# 出货仓库
select_out_warehouse = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[8]/div'
out_warehouse = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[8]/div/div/ul/li'
# 订单模式
select_order_schema = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[9]/div'


def order_schema(num):
    return get_select('/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[9]/div/div/ul/li[1]', num)


# 来源
select_source = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[10]/div'


def source_web(num):
    return get_select('/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[10]/div/div/ul/li[1]', num)


# 地址信息
input_address_info = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[11]/input'

# 订单售后
order_after = By.XPATH, '//*[@id="power-menu-177"]/li[2]/a'
# 售后原因
input_after_cause = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[5]/input'
# 退款类型
select_refund_type = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[9]/div/ul/li'


def refund_type(num):
    return get_select('/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[9]/div/div/ul/li[1]', num)


# 退款说明
input_refund_explain = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[8]/input'
# 快递公司
input_courier_services = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[10]/input'
# 快递单号
input_courier_number = By.XPATH, '/html/body/div[2]/div/form/div[3]/table/thead/tr[2]/td[11]/input'
